22 research outputs found

    Towards a Java Subtyping Operad

    Full text link
    The subtyping relation in Java exhibits self-similarity. The self-similarity in Java subtyping is interesting and intricate due to the existence of wildcard types and, accordingly, the existence of three subtyping rules for generic types: covariant subtyping, contravariant subtyping and invariant subtyping. Supporting bounded type variables also adds to the complexity of the subtyping relation in Java and in other generic nominally-typed OO languages such as C# and Scala. In this paper we explore defining an operad to model the construction of the subtyping relation in Java and in similar generic nominally-typed OO programming languages. Operads, from category theory, are frequently used to model self-similar phenomena. The Java subtyping operad, we hope, will shed more light on understanding the type systems of generic nominally-typed OO languages.Comment: 13 page

    Java and scala's type systems are unsound: the existential crisis of null pointers

    Get PDF
    We present short programs that demonstrate the unsoundness of Java and Scala's current type systems. In particular, these programs provide parametrically polymorphic functions that can turn any type into any type without (down) casting. Fortunately, parametric polymorphism was not integrated into the Java Virtual Machine (JVM), so these examples do not demonstrate any unsoundness of the JVM. Nonetheless, we discuss broader implications of these findings on the field of programming languages

    The Expression Problem Revisited — Four new solutions using generics

    No full text
    Abstract. The expression problem (aka the extensibility problem) refers to a fundamental dilemma of programming: To which degree can your application be structured in such a way that both the data model and the set of virtual operations over it can be extended without the need to modify existing code, without the need for code repetition and without runtime type errors. Over the years, many approaches to this problem have been proposed, each having different characteristics of type safety and reusability. While many of these rely on exotic or problem specific language extensions, this paper investigates the solution space within the framework of the soonto-be mainstream generic extensions of C # and the Java programming language. Four new solutions are presented which, though quite different, all rely on techniques that can be used in everyday programming.

    Unifying Genericity: Combining the Benefits of Virtual Types and Parameterized Classes

    No full text
    . Generic types in programming languages are most often supported with various forms of parametric polymorphism, i.e. functions on types. Within the framework of object-oriented languages, virtual types present an alternative where specic types are derived from generic ones using inheritance rather than function application. While both mechanisms are statically safe and support basic genericity, they have very dierent typing properties, each of them providing for the description of useful relationships, which are not expressible with the other. In this paper we present, through the use of examples, a mechanism for describing generic classes: structural virtual types. This mechanism is essentially a merger of parameterized classes and virtual types and includes the bene ts of both, in particular retaining mutual recursion and covariance of virtual types as well as the function-like nature of parameterized classes. 1 Introduction The term genericity in our use covers the ..

    Variant Path Types for Scalable Extensibility

    No full text
    Much recent work in the design of object-oriented programming languages has been focusing on identifying suitable features to support so-called scalable extensibility, where the usual extension mechanism by inheritance works in different scales of software components—that is, classes, groups of classes, groups of groups and so on. Mostly, this issue has been addressed by means of dependent type systems, where nested types are seen as properties of objects. In this work, we seek instead for a different and possibly simpler solution, retaining the Java-like approach of nested types as properties of classes. We introduce the mechanism of variant path types, which provides a flexible means to intra-group relationship (among classes) that has to be preserved through extension. Featuring the new notions of exact and inexact qualifications, these types also provide rich abstractions to express various kinds of set of objects, thanks to a flexible subtyping mechanism. We formalize a safe type system for variant path types on top of Featherweight Java. Though a full study of applicability and expressiveness is ongoing work, our development currently results in a complete solution for scalable extensibility, similarly to previous attempts based on dependent type systems
    corecore